package com.doge.calcalbum.api.model

data class UserInfo(
    val id: Int,
    val openId: String?,
    val nickName: String?,
    val profilePicture: String?,
    val vipExpireTimestamp: Long?, // 显示在界面上的时间 时间戳
    val vipExpireLeftTime: Long?, // 还有多久过期
    val canGetFreeVip: Int?, // 1免费限时vip
    val fuc: Int?, // free upload count
) {
    val isVipForever: Boolean get() = vipExpireLeftTime == -1L
    val isVip: Boolean get() = isVipForever || (vipExpireLeftTime ?: 0) > 0
    val isVipJust7Day: Boolean
        get() {
            val just7Day = (vipExpireLeftTime ?: 0) < (DAY7)
            return isVip && just7Day
        }
    val wasVip: Boolean get() = !isVip && vipExpireTimestamp != null && vipExpireTimestamp != 0L
    val wasVip7Day: Boolean
        get() {
            val expiredIn7Day =
                (vipExpireTimestamp ?: 0L) > System.currentTimeMillis() - (DAY7)
            return wasVip && expiredIn7Day
        }

    companion object {
        private const val DAY7 = 7 * 24 * 3600 * 1000
        val EMPTY = UserInfo(
            0, "", "游客", "",
            0, 0,  0,10
        )
    }
}